package cc.chenwenxi.mypi.appium.entity.app;

import cc.chenwenxi.mypi.appium.kits.AppiumDriverWait;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.Activity;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.pagefactory.AndroidFindBy;
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
import org.openqa.selenium.support.PageFactory;

public class 快手极速 {
    //com.ss.android.ugc.aweme.lite/com.ss.android.ugc.aweme.main.MainActivity
    public static final Activity mainActivity = new Activity("com.kuaishou.nebula", "com.yxcorp.gifshow.HomeActivity");

    public static class 首页{

        private final AppiumDriverWait wait;
        private final AppiumDriver driver;
        @AndroidFindBy(id = "com.kuaishou.nebula:id/like_icon")
        private AndroidElement 点心;

        @AndroidFindBy(id = "com.kuaishou.nebula:id/comment_icon")
        private AndroidElement 评论;

        public AndroidElement get点心() {
            wait.untilMy(driver,点心);
            return 点心;
        }

        public AndroidElement get评论() {
            wait.untilMy(driver,评论);
            return 评论;
        }

        public 首页(AppiumDriver driver) {
            PageFactory.initElements(new AppiumFieldDecorator(driver), this);
            wait = new AppiumDriverWait(driver, 60);
            this.driver = driver;
        }

    }
    
    
    public static class 导航{
        private final AppiumDriverWait wait;
        private final AppiumDriver driver;

//        @AndroidFindBy(accessibility = "首页")
        @AndroidFindBy(xpath = "//androidx.appcompat.app.ActionBar.c[@content-desc=\"首页\"]")
        private AndroidElement 首页导航;

//        @AndroidFindBy(accessibility = "去赚钱")
        @AndroidFindBy(xpath = "//androidx.appcompat.app.ActionBar.c[@content-desc=\"去赚钱\"]")
        private AndroidElement 去赚钱导航;



        @AndroidFindBy(xpath = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.TextView")
        private AndroidElement 剩余时间;

        public AndroidElement get剩余时间() {
            wait.untilMy(driver,剩余时间);
            return 剩余时间;
        }

        public AndroidElement get首页导航() {
            wait.untilMy(driver,首页导航);
            return 首页导航;
        }

        public AndroidElement get去赚钱导航() {
            wait.untilMy(driver,去赚钱导航);
            return 去赚钱导航;
        }

        public 导航(AppiumDriver driver) {
            PageFactory.initElements(new AppiumFieldDecorator(driver), this);
//            wait = new AppiumDriverWait(driver, 20,20);
            wait = new AppiumDriverWait(driver,20);
            this.driver = driver;
        }
    }
    
}
